// Variable.h: interface for the Variable class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_VARIABLE_H__E4E32F2D_29EE_46DB_B183_8BB466D80A67__INCLUDED_)
#define AFX_VARIABLE_H__E4E32F2D_29EE_46DB_B183_8BB466D80A67__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Map.h"
#include "stackInterface.h"
#include "globalshare.h"
#include "SmallObject.h"

class Variable;
typedef _declspec(dllexport) StackInterface<CString, Variable*, Variable*> PropertyStackInterface;
class Part;
class _declspec(dllexport) Variable : public SmallObject  
{
	UE_DECLARE_DYNAMIC(Variable);
public:
	enum TokenType{
		ID,
			NUM,
	};
	enum VarType{
		INTEGER,
			STRING,
			DOUBLEX,
			PART};
	enum VarState{UNKNOWN,
			KNOWN,
			MODIFY};
public:
	Variable();
	Variable(const Variable& Value);
	
public:
	virtual ~Variable();
				
public:
	virtual Variable& operator=(const CString& Value);
	virtual Variable& operator=(const Variable& Value);
	virtual Variable& operator=(const _variant_t& Value);
	virtual Variable& operator=(const INT& Value);
	virtual Variable& operator=(const DOUBLE& Value);
	virtual Variable& operator=(const LONG& Value);
	virtual Variable& operator=(const SHORT& Value);
	virtual Variable& operator=(const FLOAT& Value);
	virtual Variable operator-();
	
	Variable operator+(Variable& Value);
	Variable operator-(Variable& Value);
	Variable operator*(Variable& Value);
	Variable operator/(Variable& Value);
	Variable operator>=(Variable& Value);
	Variable operator==(Variable& Value);
	Variable operator<=(Variable& Value);
	Variable operator>(Variable& Value);
	Variable operator<(Variable& Value);
	Variable operator!=(Variable& Value);
	Variable operator&&(Variable& Value);
	Variable operator||(Variable& Value);
	
	virtual operator DOUBLE ();
	virtual operator FLOAT();
	virtual operator _variant_t();
	virtual operator LONG();
	virtual operator INT();
	virtual operator SHORT();
	virtual operator CString();
	virtual operator Part*();
	virtual operator PropertyStackInterface*();
	
	const CString& GetSymbol(){
		return m_strSymbol;
	}
	
	VarType DataType(){
		return m_nDataType;
	}
	
	
	void Symbol(const CString& strSymbol){
		m_strSymbol = strSymbol;
		m_strSymbol.MakeUpper();
	}
	
public:
	void DataType(VarType nType){
		m_nDataType = nType;
	}
	
	BOOL IsKnown(){
		if(m_nState == KNOWN || m_nState == MODIFY)
			return TRUE;
		return FALSE;
	}

	BOOL IsModify(){
		if(m_nState == MODIFY)
			return TRUE;
		return FALSE;
	}

	void SetKnown(){
		m_nState = KNOWN;
	}

private:
	VarState m_nState;
	TokenType m_nType;
	VarType m_nDataType;
	CString m_strSymbol;
	_variant_t m_Value;
};

#endif // !defined(AFX_VARIABLE_H__E4E32F2D_29EE_46DB_B183_8BB466D80A67__INCLUDED_)
